import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/net/post_request.dart';
import 'package:ls_work/net/response/response_data.dart';
import 'package:ls_work/net/response/service_order_process_list.dart';

class ServiceOrderProcessViewModel extends BaseListViewModel<ServiceOrderProcessList>{
  final String id;
  ServiceOrderProcessViewModel(BuildContext context,this.id) : super(context);

  @override
  Future<List<ServiceOrderProcessList>> requestListData() async {
    var map = await PostRequest.serviceOrderProcess(id);
    var res = ResponseBean.fromJson(map);
    if("0"==res.code){
      var list = ((res.data['list'] as List?)??[]).map((e) => ServiceOrderProcessList.fromJson(e)).toList();
      return list??[];
    }else{
      throw res.msg??"";
    }
  }
  
  @override
  void onCreated() {
    super.onCreated();
    requestRefresh(showAni: false);

  }
}